<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<!-- 
     const声明的是常量 一旦声明 就不能重新赋值
      重复声明:已经存在的变量，又声明了一遍
      var 允许重复声明、
      let const不允许重复声明
 -->

<body>
    <script>
        // var a = 1;
        // var a = 4;
        // console.log(a); //4

        //let不允许重复声明
        //  let a = 2;
        //  let a = 3;
        //  console.log(a);
        //报错：Uncaught SyntaxError: Identifier 'a' has already been declared

        //let不允许重复声明
        //function func(a) {
        //    let a = 10;
        //}

        // func(); //Uncaught SyntaxError: Identifier 'a' has already been declared
        //var会提升变量的声明到当前作用域的顶部
        // console.log(a);
        //undefined
        //相当于
        var a;
        console.log(a);
        a = 10;
        console.log(a);
    </script>
</body>

</html>